import './show_post.html';


import { Template } from 'meteor/templating';


Template.show_post_modal.onCreated(function(){
  let self = this;
  self.title = new ReactiveVar("载入中");
  self.body = new ReactiveVar("载入中");
  self.author = new ReactiveVar("载入中");
  self.createdAt = new ReactiveVar("载入中");
  self.autorun(function(c){
    let post = Session.get('one-post-show');
    if (post != undefined) {
      self.title.set(post.title);
      self.body.set(post.body);
      self.author.set(post.author);
      self.createdAt.set(post.createdAt);
    }

  });

})


Template.show_post_modal.onRendered(function(instance){
  	// $('.ui.modal').modal({
    //   onShow: function(){
    //
    //   }
    // });
});

Template.show_post_modal.helpers({
  image(){
    return 'https://uploadbeta.com/api/pictures/random/?key=Computing';
  },
  title(){
    return Template.instance().title.get();
  },
  body(){
    return Template.instance().body.get();
  },
  author(){
    return Template.instance().author.get();
  },
  createdAt(){
    let date = Template.instance().createdAt.get();
    date = moment(date).format('YYYY年MMMMDD日, HH:mm:ss');
    return date;
  }

});

Template.show_post_modal.events({
  "click #foo": function(event, template){

  }
});
